package org.mdrtwell.jdk15;

import java.util.ArrayList;

public class Card {
	public enum Rank {
		DEUCE, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE
	}

	public enum Suit {
		CLUBS, DIAMONDS, HEARTS, SPADES
	}

	private final Rank	rank;
	private final Suit	suit;

	public Rank rank() {
		return rank;
	}

	public Suit suit() {
		return suit;
	}

	Card(Rank r,
			Suit s) {
		this.rank = r;
		this.suit = s;
	}

	@Override
	public String toString() {
		return rank + " of " + suit;
	}

	private static final ArrayList<Card>	protoDeck	= new ArrayList<Card>();
	static {
		for (Rank r : Rank.values()) {
			for (Suit suit : Suit.values()) {
				Card card = new Card(r, suit);
				protoDeck.add(card);
			}
		}
	}

	public static ArrayList<Card> newDeck() {
		return new ArrayList<Card>(protoDeck);// Return copy of prototype deck
												// ��㸴��
	}

	public static void main(String[] args) {
		for (Card c : protoDeck) {
			System.out.println(c);
		}
	}
}
